package com.hjxr.sysadmin.zsj.controller;

import java.util.List;

import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.controller.BaseController;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import com.hjxr.sysadmin.zsj.domain.CompanyZ;
import com.hjxr.sysadmin.zsj.service.ICompanyZService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;


/**
 * 企业详情Controller
 *
 * @author hjxr
 * @date 2021-03-22
 */
@Api("企业详情")
@RestController
@RequestMapping("/company")
public class CompanyZController extends BaseController
{
    @Autowired
    private ICompanyZService companyZService;

    /**
     * 查询企业详情列表
     */
    @ApiOperation("查询企业详情列表")
    @GetMapping("/list")
    public TableDataInfo list(CompanyZ companyZ)
    {
        startPage();
        List<CompanyZ> list = companyZService.selectCompanyZList(companyZ);
        return getDataTable(list);
    }

    /**
     * 导出企业详情列表
     */
    @ApiOperation("导出企业详情列表")
    @Log(title = "企业详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanyZ companyZ)
    {
        List<CompanyZ> list = companyZService.selectCompanyZList(companyZ);
        ExcelUtil<CompanyZ> util = new ExcelUtil<CompanyZ>(CompanyZ.class);
        return util.exportExcel(list, "z");
    }

    /**
     * 获取企业详情详细信息
     */
    @ApiOperation("获取企业详情详细信息")
    @GetMapping(value = "/{companyId}")
    public AjaxResult getInfo(@PathVariable("companyId") Long companyId)
    {
        return AjaxResult.success(companyZService.selectCompanyZById(companyId));
    }

    /**
     * 新增企业详情
     */
    @ApiOperation("新增企业详情")
    @Log(title = "企业详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyZ companyZ)
    {
        return toAjax(companyZService.insertCompanyZ(companyZ));
    }

    /**
     * 修改企业详情
     */
    @ApiOperation("修改企业详情")
    @Log(title = "企业详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyZ companyZ)
    {
        return toAjax(companyZService.updateCompanyZ(companyZ));
    }

    /**
     * 删除企业详情
     */
    @ApiOperation("删除企业详情")
    @Log(title = "企业详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{companyIds}")
    public AjaxResult remove(@PathVariable Long[] companyIds)
    {
        return toAjax(companyZService.deleteCompanyZByIds(companyIds));
    }
}
